#ifndef TEXTURE2D_H_
#define TEXTURE2D_H_

#include "Img.h"
#include <SDL_opengl.h>
#include "Asset.h"
#include "DebugSys.h"
#include "Rect.h"

class Texture2D : public Asset
{
private:
	GLuint tex; // Texture ID in OpenGL
	int texWidth, texHeight; // Texture sizes

	bool padded; // W-o-N the texture is padded

	// Power of two operations
	bool isPowerOfTwo(int x);
	int NextPowerOfTwo(int x);

	// Rect used for padding
	Rect pad;

public:
	Texture2D(void);
	~Texture2D(void);

	void Bind(); // Bind the texture in OpenGL

	// Generate a texture using an SDL_Surface
	void Gen(Img &img, bool doPadding = true);
	void Gen(SDL_Surface* sur, bool doPadding = true);
	void Delete(); // Delete the texture

	// Get the texture sizes
	inline int Width() { return texWidth; }
	inline int Height() { return texHeight; }

	// Get padding properties
	inline bool isPadded() { return padded; }
	inline Rect &Pad() { return pad; }

	// Debug the texture
	std::string Debug();
};

#endif // TEXTURE2D_H_

